/**
 * Created by dizhihao on 16/9/13.
 */

$(function () {
    // 登陆
    var modal1 = '';
    modal1 += '<div class="modal-dialog">';
    modal1 += ' <div class="modal-content" style="width: 100%; top: 140px; margin: 0 auto;">';
    modal1 += '     <div class="modal-header ui-draggable-handle" style="padding:0px">';
    modal1 += '         <div class="modal-header">';
    modal1 += '             <button type="button" class="close" data-dismiss="modal" aria-label="Close">';
    modal1 += '                 <span aria-hidden="true">×</span>';
    modal1 += '             </button>';
    modal1 += '             <h4 class="modal-title font-green">登 陆 &nbsp;';
    modal1 += '                 <span style="color: red;font-size: 14px" id="warn"></span>';
    modal1 += '             </h4>';
    modal1 += '         </div>';
    modal1 += '     </div>';
    modal1 += '     <div class="modal-body">';
    modal1 += '         <div class="form-group">';
    modal1 += '             <label>用户名</label>';
    modal1 += '             <div class="input-group">';
    modal1 += '                 <span class="input-group-addon"><i class="fa fa-envelope"></i></span>';
    modal1 += '                 <input class="form-control" placeholder="您注册时所用的邮箱" name="email" type="text">';
    modal1 += '             </div>';
    modal1 += '         </div>';
    modal1 += '         <div class="form-group">';
    modal1 += '             <label>密 码</label>';
    modal1 += '             <div class="input-group">';
    modal1 += '                 <span class="input-group-addon"><i class="fa fa-user"></i></span>';
    modal1 += '                 <input class="form-control" placeholder="您注册时所用的电话号码" name="phone" type="password">';
    modal1 += '             </div>';
    modal1 += '         </div>';
    modal1 += '         <div class="form-actions row" style="overflow: hidden;">';
    modal1 += '             <div class="col-md-9" style="float: left;">';
    modal1 += '                 还没有招标猫账号？免费<a href="javascript:signupShow();" id="register-btn" style="color: red">注册</a>';
    modal1 += '             </div>';
    modal1 += '             <div class="col-md-3" style="float: right;">';
    modal1 += '                 <button type="button" onclick="toLogin()" class="btn btn-primary">登陆</button>';
    modal1 += '                 <button type="button" onclick="dlClose()" class="btn btn-default" style="background-color: #e0e0e0">';
    modal1 += '                     取消</button>';
    modal1 += '             </div>';
    modal1 += '         </div>';
    modal1 += '     </div>';
    modal1 += ' </div>';
    modal1 += '</div>';

    var loginModal = $('#loginModal');
    loginModal.tabindex = "-1";
    loginModal.role = "dialog";
    loginModal.html(modal1);

    // 注册
    var modal2 = '';
    modal2 += '<div class="modal-dialog">';
    modal2 += '  <div class="modal-content" style="width: 100%; top: 130px; margin: 0 auto;">';
    modal2 += '      <div class="modal-header ui-draggable-handle" style="padding:0px">';
    modal2 += '          <div class="modal-header">';
    modal2 += '              <button type="button" class="close" data-dismiss="modal" aria-label="Close">';
    modal2 += '                  <span aria-hidden="true">×</span>';
    modal2 += '              </button>';
    modal2 += '              <h4 class="form-title font-green">注 册';
    modal2 += '                 <span style="font-size: 13px;">（注：<span style="color: red">*</span>';
    modal2 += '                     为必填项）<span style="color: red;font-size: 18px" id="unknown01"></span>';
    modal2 += '                 </span>';
    modal2 += '              </h4>';
    modal2 += '         </div>';
    modal2 += '     </div>';
    modal2 += '     <div class="modal-body">';
    modal2 += '         <div class="form-group">';
    modal2 += '             <label>您的邮件地址</label>&nbsp;<span style="color: red">*</span>';
    modal2 += '             <span style="color: #000;font-size: 13px;"> </span>';
    modal2 += '             <span id="username_span" style="margin-left: 20px;font-size: 0.8em;color: red;"></span>';
    modal2 += '             <div class="input-group">';
    modal2 += '                 <span class="input-group-addon"><i class="fa fa-envelope"></i></span>';
    modal2 += '                 <input style="width: 100%;" class="form-control" ';
    modal2 += '                     placeholder="您的邮件地址会作为登陆招标猫的用户名" name="email_zc" type="text">';
    modal2 += '             </div>';
    modal2 += '         </div>';
    modal2 += '         <div class="form-group">';
    modal2 += '             <label>您的电话</label>&nbsp;<span style="color: red">*</span>';
    modal2 += '             <span style="color: #000;font-size: 13px;"> </span>';
    modal2 += '             <span id="phone_span" style="margin-left: 20px;font-size: 0.8em;color: red;"></span>';
    modal2 += '             <div class="input-group">';
    modal2 += '                 <span class="input-group-addon"><i class="icon-screen-smartphone"></i></span>';
    modal2 += '                 <input style="width: 100%;" class="form-control" placeholder="您的电话会作为登陆招标猫的密码" ';
    modal2 += '                     name="phone_zc" type="text">';
    modal2 += '             </div>';
    modal2 += '         </div>';
    modal2 += '         <div class="form-actions right" style="margin-top: 40px;height: 30px">';
    modal2 += '             <div style="float: right">';
    modal2 += '                 <button type="button" class="btn btn-primary" onclick="signupSubmit()">注册</button>';
    modal2 += '                 <button type="button" class="btn btn-default" onclick="signupClose()" ';
    modal2 += '                     style="background-color: #e0e0e0">取消';
    modal2 += '                 </button>';
    modal2 += '             </div>';
    modal2 += '         </div>';
    modal2 += '     </div>';
    modal2 += '  </div>';
    modal2 += '</div>';

    var registerModal = $('#registerModal');
    registerModal.tabindex = "-1";
    registerModal.role = "dialog";
    registerModal.html(modal2);
});

// 登录
function toLogin() {
    $('#loginModal').modal('hide');
}

// 登录取消
function dlClose() {
    $('#loginModal').modal('hide');
}

// 跳转到注册
function signupShow() {
    $('#loginModal').modal('hide');
    $('#registerModal').modal('show');
}

// 注册
function signupSubmit() {
    $('#registerModal').modal('hide');
}

// 注册取消
function signupClose() {
    $('#registerModal').modal('hide');
}